package com.example.battle.db;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import com.example.battle.entity.FansName;
import com.example.battle.entity.Feedback;
import com.example.battle.entity.User;

import java.util.List;

@Dao
public interface BattleDao {

    @Insert
    void initFansName(FansName...fansNames);

    @Query("select * from User")
    List<User> findAll();

    @Query("select count(fans_name) from FansName")
    int getUserNum();

    @Insert
    void register(User user);

    @Query("select * from User where user_id = (:userId)")
    List<User> findTheSameName(String userId);

    @Query("select * from User where user_id = (:userId)")
    User login(String userId);

    @Update(onConflict = OnConflictStrategy.REPLACE)
    void updateUserInfo(User user);

    @Insert
    void registerFansName(FansName fansName);

    @Query("select * from FansName LIMIT 25")
    List<FansName> getBallData();

    @Query("select * from FansName where fans_name like ('%' || :fansName || '%')")
    List<FansName> searchFansNameItems(String fansName);

    @Query("select * from FansName where fans_name = (:fansName)")
    FansName searchFansName(String fansName);

    @Insert
    void addFeedback(Feedback feedback);
}
